package com.tsingteng.cosfun.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.tsingteng.cosfun.R;


/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/8/31
 * qq(872179966)
 */

public class WarningDialog {
    private Context context;
    private Dialog dialog;

    public WarningDialog(Context context) {
        this.context = context;
        initView();
    }

    private void initView() {
        dialog = new Dialog(context, R.style.dialog);
        dialog.setContentView(R.layout.dialog_content_warning);
        ImageView imageView = dialog.findViewById(R.id.iv_warning);
        TextView textView = dialog.findViewById(R.id.tv_warning);
    }

    public void show() {
        Window dialogWindow = dialog.getWindow();
        WindowManager.LayoutParams attributes = dialogWindow.getAttributes();
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();// 获取屏幕宽、高用
        attributes.width = (int) (displayMetrics.widthPixels * 0.8); // 高度设置为屏幕的0.6
        dialogWindow.setAttributes(attributes);
        if (dialog.isShowing()) {
            dialog.dismiss();
        }
        dialog.show();

    }

    public void dissMiss() {
        if (dialog !=null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}
